Streamflow + precipitation (daily cumulative) + manual checks
#format precipitation data for a smooth joining process
precip_daily_join <- precip_daily_clean %>%
pivot_wider(
names_from = "precip_type",
values_from = "precip_in"
) %>%
subset(year <= 2019 & year >= 2017)
#join streamflow and daily precipitation data
streamflow_precip_daily <- full_join(x = all_streamflow, y = precip_daily_join, by = "date") %>%
rename(precip_10_in = precip_10) %>%
select(-precip_in) %>%
subset(year <= 2019 & year >= 2017)
#plot
p_spmc <- ggplot() +
#precipitation data
geom_line(data = streamflow_precip_daily,
aes(x = date,
y = precip_10_in,
colour = I("grey")),
size = 0.25) +
#streamflow data
geom_line(data = all_streamflow,
aes(x = date,
y = stream_height_ft),
color = "blue",
size = 0.25) +
#manual check points
geom_point(data = mc_clean,
aes(x = date, y = stripchart_stage),
size = 0.5) +
theme_classic() +
labs(x = "Time",
title = "2017 - 2019 S2 Bog Streamflow and Daily Cumulative Precipitation",
subtitle = "Streamflow is plotted in blue. \n Precipitation is plotted in grey. \n Manual streamflow checks are plotted as black points.") +
theme(plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5,
size = 7)) +
scale_y_continuous(
#features of the first axis
name = "Stream Height (ft)",
#add a second axis and specify its features
##determine the ratio between the max value of Axis 1 vs the max value of Axis 2 to decide what number to put in the trans argument
###for example, max value of precipitation / max value of streamflow = 0.533...
sec.axis = sec_axis(trans = ~.*0.53326422081, name = "Cumulative Daily Precipitation / 10 (in)")
)
#static plot
#p_spmc
#save the plot in the figures folder
ggsave(filename = "streamflow_precip_manual_checks.png",
plot = p_spmc,
path = "figures/",
width = 8,
height = 4,
units = c("in"),
dpi = 300)
#interactive plot
ggplotly(p_spmc)
Streamflow + air temperature data (every 30min) + manual checks
#format air temperature data for plotting
airtemp_join <- air_temp_30_clean %>%
pivot_wider(
names_from = "airtemp_type",
values_from = "airtempC"
) %>%
subset(year >= 2017 & year <= 2019)
#plot
p_samc <- ggplot() +
#airtemp data
geom_line(data = airtemp_join,
aes(x = datetime,
y = airtempc_100),
color = "pink",
alpha = 0.5,
size = 0.25) +
#streamflow data
geom_line(data = all_streamflow,
aes(x = datetime,
y = stream_height_ft),
color = "blue",
size = 0.25) +
#manual check points
geom_point(data = mc_clean,
aes(x = collected, y = stripchart_stage),
size = 0.5) +
theme_classic() +
labs(x = "Time",
title = "S2 Bog Streamflow and Air Temperature (2017 - 2019)",
subtitle = "Air temperature is plotted in pink. \n Streamflow is plotted in blue. \n Manual streamflow checkpoints are plotted as black dots.") +
theme(plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0.5,
size = 7)) +
scale_y_continuous(
# Features of the first axis
name = "Air Temperature / 100 (ÂșC)",
# Add a second axis and specify its features
sec.axis = sec_axis(trans = ~.*1, name = "Stream Height (ft)")
)
#static plot
#p_samc
#save the plot in the figures folder
ggsave(filename = "streamflow_airtemp_manual_checks.png",
plot = p_samc,
path = "figures/",
width = 6,
height = 4,
units = c("in"),
dpi = 300)
#interactive plot
ggplotly(p_samc)